﻿using System.Runtime.Serialization;
using Ping.Core;

namespace Ping.App
{
	/// <summary>
	/// Can hold the relevant state of this application.
	/// </summary>
	[DataContract]
	public sealed class State
	{
		private Connection _connection;
		private Scheduler _scheduler;

		public void Init()
		{
			_connection = new Connection();
			_scheduler = new Scheduler(_connection);
		}

		/// <summary>
		/// The one and only connection to the server.
		/// </summary>
		public Connection Connection { get { return _connection; } }

		/// <summary>
		/// The one and only job-scheduler.
		/// </summary>
		public Scheduler Scheduler { get { return _scheduler; } }

		/// <summary>
		/// Value of the textbox in the MainPage.
		/// </summary>
		[DataMember]
		public string IpOrHost;

		/// <summary>
		/// The result of the dns lookup (may be null).
		/// </summary>
		[DataMember]
		public Result DnsResult;

		/// <summary>
		/// The result of the traceroute (may be null).
		/// </summary>
		[DataMember]
		public Result TraceResult;

		/// <summary>
		/// The result of the ip/geo-lookup (may be null).
		/// </summary>
		[DataMember]
		public Result GeoResult;
	}
}